import React, {
	Component
} from 'react';
import {
    toJS
} from 'mobx';
import {
	observer,
} from 'mobx-react';
import { List,Avatar } from 'weaver-mobile';
import NoData from "../my/NoData.js";
import {addContentPath} from '../../../util/public-func.js'
const Item = List.Item;
const Brief = Item.Brief;

@observer
export default class ListInfo extends Component {
	handleClick = (id, name) => {
		if (window.em && window.em.checkJsApi('openLink')) {
			window.em.openLink({
				url: `/spa/hrm/static4mobile/index.html#/subAttendanceCopy/${id}`,
		        openType: 2,
		        sysId: window.localStorage.emobile_ec_id
			});
		}else{
			 window.location.href = addContentPath(`/spa/hrm/static4mobile/index.html#/subAttendanceCopy/${id}`);
		}
	}
	
	render() {
		const {
			store
		} = this.props, {
			subordinateDataSource
		} = store;

		if (subordinateDataSource.length === 0) {
			return (
				<NoData />
			)
		}

		return (
			<List>
				{
					subordinateDataSource.map(data => {
						const {id, img,lastname,jobtitlename,subcompanyname,departmentname} = data;
						return (
							<Item
					          arrow="horizontal"
					          thumb={<Avatar userId={id}/>}
					          multipleLine
					          arrow="empty"
					          onClick={() => this.handleClick(id, lastname)}
					        >
					          <span>{lastname}</span>
					          <span>{jobtitlename}</span>
					          <Brief>
					          	<span>{subcompanyname}</span>
					          	<span>{departmentname}</span>
					          </Brief>
					        </Item>
						)
					})
				}
			</List>
		);
	}
}
